/**
*	搜索
**/
app.controller('gSearchCtrl', ['$scope', '$state', '$stateParams', '$http', '$sce', 'utils',
  function($scope, $state, $stateParams, $http, $sce, utils) {
    // 搜索条件
    $scope.searchParams = {
      type: '5',
      typeName: '预警信息',
      searchVal: '',
      placeholder: '在预警信息中搜索',
      keyWords: ''
    }

    $scope.isViewDetail = false;

    // 搜索条件
    $scope.searchRsLists = [];

    // 改变分类
    $scope.changeSearchType = function (type, typeName) {
      $scope.searchParams.type = type;
      $scope.searchParams.typeName = typeName;
      $scope.searchParams.placeholder = '在'+typeName+'中搜索';
    }

    // 执行搜索
    $scope.doSearch = function () {
      $scope.loading = true;
      // 获取预警快报列表信息
      utils.get('searchList', {
        type: $scope.searchParams.type,
        keyWords: $scope.searchParams.keyWords
      }).success(function (rs) {
        $scope.loading = false;
        $scope.searchRsLists = rs.data;
      });
    }

    // 查看详情
    $scope.viewDetail = function (id) {
      $scope.isViewDetail = true;
      $scope.detailId = id;
      $scope.detailType = 'i';
    }

    // 切换状态
    $scope.changeIsViewDetail = function () {
      $scope.isViewDetail = false;
    }

  }
]);
